package com.irdstudio.efp.rule.service.impl;

import java.util.List;
import java.util.Objects;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.irdstudio.basic.framework.core.base.FrameworkService;
import com.irdstudio.efp.rule.service.facade.TaxAgainstLawInfoService;
import com.irdstudio.efp.rule.service.dao.TaxAgainstLawInfoDao;
import com.irdstudio.efp.rule.service.domain.TaxAgainstLawInfo;
import com.irdstudio.efp.rule.service.vo.TaxAgainstLawInfoVO;


/**
 * Service Impl: 违法违章信息表服务实现
 * @author ligm
 * @date 2019-04-29 
 */
@Service("taxAgainstLawInfoService")
public class TaxAgainstLawInfoServiceImpl implements TaxAgainstLawInfoService, FrameworkService {
	
	private static Logger logger = LoggerFactory.getLogger(TaxAgainstLawInfoServiceImpl.class);

	@Autowired
	private TaxAgainstLawInfoDao taxAgainstLawInfoDao;

   	/**
	 * 新增数据 
     * @param inTaxAgainstLawInfoVo
     * @return 
	 */
	public int insertTaxAgainstLawInfo(TaxAgainstLawInfoVO inTaxAgainstLawInfoVo) {
		logger.debug("当前新增数据为:"+ inTaxAgainstLawInfoVo.toString());
		int num = 0;
		try {
			TaxAgainstLawInfo taxAgainstLawInfo = new TaxAgainstLawInfo();
			beanCopy(inTaxAgainstLawInfoVo, taxAgainstLawInfo);
			num = taxAgainstLawInfoDao.insertTaxAgainstLawInfo(taxAgainstLawInfo);
		} catch (Exception e) {
			logger.error("新增数据发生异常!", e);
			num = -1;
		}
		logger.debug("当前新增数据条数为:"+ num);
		return num;
	}

    /**
	 * 根据主键删除信息 
	 * @param inTaxAgainstLawInfoVo
 	 * @return
	 */
	public int deleteByPk(TaxAgainstLawInfoVO inTaxAgainstLawInfoVo) {
		logger.debug("当前删除数据条件为:"+ inTaxAgainstLawInfoVo);
		int num = 0;
		try {
			TaxAgainstLawInfo taxAgainstLawInfo = new TaxAgainstLawInfo();
			beanCopy(inTaxAgainstLawInfoVo, taxAgainstLawInfo);
			num = taxAgainstLawInfoDao.deleteByPk(taxAgainstLawInfo);
		} catch (Exception e) {
			logger.error("删除数据发生异常!", e);
			num = -1;
		}
		logger.debug("根据条件:"+ inTaxAgainstLawInfoVo +"删除的数据条数为"+ num);
		return num;
	}


    /**
	 * 根据主键更新信息 
	 * @param inTaxAgainstLawInfoVo
	 * @return 
	 */  
	public int updateByPk(TaxAgainstLawInfoVO inTaxAgainstLawInfoVo) {
		logger.debug("当前修改数据为:"+ inTaxAgainstLawInfoVo.toString());
		int num = 0;
		try {
			TaxAgainstLawInfo taxAgainstLawInfo = new TaxAgainstLawInfo();
			beanCopy(inTaxAgainstLawInfoVo, taxAgainstLawInfo);
			num = taxAgainstLawInfoDao.updateByPk(taxAgainstLawInfo);
		} catch (Exception e) {
			logger.error("修改数据发生异常!", e);
			num = -1;
		}
		logger.debug("根据条件:"+ inTaxAgainstLawInfoVo +"修改的数据条数为"+ num);
		return num;
	}
	
    /**
	 * 根据主键查询详情 
	 * @param taxAgainstLawInfo
	 * @return 
	 */
	public TaxAgainstLawInfoVO queryByPk(TaxAgainstLawInfoVO inTaxAgainstLawInfoVo) {
		
		logger.debug("当前查询参数信息为:"+ inTaxAgainstLawInfoVo);
		try {
			TaxAgainstLawInfo queryTaxAgainstLawInfo = new TaxAgainstLawInfo();
			beanCopy(inTaxAgainstLawInfoVo, queryTaxAgainstLawInfo);
			TaxAgainstLawInfo queryRslTaxAgainstLawInfo = taxAgainstLawInfoDao.queryByPk(queryTaxAgainstLawInfo);
			if (Objects.nonNull(queryRslTaxAgainstLawInfo)) {
				TaxAgainstLawInfoVO outTaxAgainstLawInfoVo = beanCopy(queryRslTaxAgainstLawInfo, new TaxAgainstLawInfoVO());
				logger.debug("当前查询结果为:"+ outTaxAgainstLawInfoVo.toString());
				return outTaxAgainstLawInfoVo;
			} else {
				logger.debug("当前查询结果为空!");
			}
		} catch (Exception e) {
			logger.error("查询数据发生异常!", e);
		}
		return null;
	}


    /**
	 * 一级数据权限 
	 * @param taxAgainstLawInfo
	 * @return 
	 */	
	@SuppressWarnings("unchecked")
	public List<TaxAgainstLawInfoVO> queryAllByLevelOne(TaxAgainstLawInfoVO taxAgainstLawInfoVo) {
		logger.debug("查看当前用户对应的数据信息的参数信息为:");
		List<TaxAgainstLawInfoVO> list = null;
		try {
			List<TaxAgainstLawInfo> taxAgainstLawInfos = taxAgainstLawInfoDao.queryAllByLevelOneByPage(taxAgainstLawInfoVo);
			logger.debug("查看当前用户对应的数据信息的结果集数量为:"+ taxAgainstLawInfos.size());
			pageSet(taxAgainstLawInfos, taxAgainstLawInfoVo);
			list = (List<TaxAgainstLawInfoVO>) beansCopy(taxAgainstLawInfos, TaxAgainstLawInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	
	}


    /**
	 * 二级数据权限 
	 * @param taxAgainstLawInfo
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<TaxAgainstLawInfoVO> queryAllByLevelTwo(TaxAgainstLawInfoVO taxAgainstLawInfoVo) {
		logger.debug("查看当前用户及所属机构对应的数据信息的参数信息为:");
		List<TaxAgainstLawInfo> taxAgainstLawInfos = taxAgainstLawInfoDao.queryAllByLevelTwoByPage(taxAgainstLawInfoVo);
		logger.debug("查看当前用户及所属机构对应的数据信息的结果集数量为:"+taxAgainstLawInfos.size());
		List<TaxAgainstLawInfoVO> list = null;
		try {
			pageSet(taxAgainstLawInfos, taxAgainstLawInfoVo);
			list = (List<TaxAgainstLawInfoVO>) beansCopy(taxAgainstLawInfos, TaxAgainstLawInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	
	}


    /**
	 * 三级数据权限 
	 * @param taxAgainstLawInfo
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<TaxAgainstLawInfoVO> queryAllByLevelThree(TaxAgainstLawInfoVO taxAgainstLawInfoVo) {
		logger.debug("查看当前用户所在机构及下属机构对应的数据信息的参数信息为:");
		List<TaxAgainstLawInfo> taxAgainstLawInfos = taxAgainstLawInfoDao.queryAllByLevelThreeByPage(taxAgainstLawInfoVo);
		logger.debug("查看当前用户所在机构及下属机构对应的数据信息的结果集数量为:"+ taxAgainstLawInfos.size());
		List<TaxAgainstLawInfoVO> list = null;
		try {
			pageSet(taxAgainstLawInfos, taxAgainstLawInfoVo);
			list = (List<TaxAgainstLawInfoVO>) beansCopy(taxAgainstLawInfos, TaxAgainstLawInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	}

    /**
	 * 四级数据权限  
	 * @param taxAgainstLawInfo
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<TaxAgainstLawInfoVO> queryAllByLevelFour(TaxAgainstLawInfoVO taxAgainstLawInfoVo) {
		logger.debug("【预留，便于后续自定义 】信息的参数信息为:");
		List<TaxAgainstLawInfo> taxAgainstLawInfos = taxAgainstLawInfoDao.queryAllByLevelFourByPage(taxAgainstLawInfoVo);
		logger.debug("【预留，便于后续自定义 】信息的结果集数量为:"+ taxAgainstLawInfos.size());
		List<TaxAgainstLawInfoVO> list = null;
		try {
			pageSet(taxAgainstLawInfos, taxAgainstLawInfoVo);
			list = (List<TaxAgainstLawInfoVO>) beansCopy(taxAgainstLawInfos, TaxAgainstLawInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	}

    /**
	 * 五级数据权限  
	 * @param taxAgainstLawInfo
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<TaxAgainstLawInfoVO> queryAllByLevelFive(TaxAgainstLawInfoVO taxAgainstLawInfoVo) {
		logger.debug("【预留，便于后续自定义 】信息的参数信息为:");
		List<TaxAgainstLawInfo> taxAgainstLawInfos = taxAgainstLawInfoDao.queryAllByLevelFiveByPage(taxAgainstLawInfoVo);
		logger.debug("【预留，便于后续自定义 】信息的结果集数量为:"+ taxAgainstLawInfos.size());
		List<TaxAgainstLawInfoVO> list = null;
		try {
			pageSet(taxAgainstLawInfos, taxAgainstLawInfoVo);
			list = (List<TaxAgainstLawInfoVO>) beansCopy(taxAgainstLawInfos, TaxAgainstLawInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	}

	@Override
	public List<TaxAgainstLawInfoVO> queryAllByLmtApplySeq(TaxAgainstLawInfoVO taxAgainstLawInfoVO) {
		logger.debug("【预留，便于后续自定义 】信息的参数信息为:");
		List<TaxAgainstLawInfo> taxAgainstLawInfos = taxAgainstLawInfoDao.queryAllByLmtApplySeq(taxAgainstLawInfoVO);
		logger.debug("【预留，便于后续自定义 】信息的结果集数量为:"+ taxAgainstLawInfos.size());
		List<TaxAgainstLawInfoVO> list = null;
		try {
			pageSet(taxAgainstLawInfos, taxAgainstLawInfoVO);
			list = (List<TaxAgainstLawInfoVO>) beansCopy(taxAgainstLawInfos, TaxAgainstLawInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	}
}
